package com.example.common.utils;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author 王鹤蒲
 * @Date 2023 10 12
 */

@Slf4j
public class AbstractEasyExcel {
//    public static void setHeader(HttpServletResponse response,String fileName){
//        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
//        response.setCharacterEncoding("utf-8");
//        try {
//            fileName= URLEncoder.encode(fileName,"utf-8").replaceAll("\\+","%20");
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//            log.error("编码异常");
//        }
//        response.setHeader("Content-disposition","attachment;filename*=utf-8''"+fileName+".xlsx");
//    }
//
//
//    public static HorizontalCellStyleStrategy formatExcel() {
//        WriteCellStyle headWriteCellStyle = new WriteCellStyle();
//        headWriteCellStyle.setFillBackgroundColor(IndexedColors.WHITE.getIndex());
//        WriteFont headWriteFont = new WriteFont();
//        headWriteFont.setFontHeightInPoints((short) 10);
//        headWriteCellStyle.setWriteFont(headWriteFont);
//        // 内容的策略
//        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
//        WriteFont contentWriteFont = new WriteFont();
//        // 字体大小
//        contentWriteFont.setFontHeightInPoints((short) 10);
//        contentWriteCellStyle.setWriteFont(contentWriteFont);
//        // 设置自动换行
//        contentWriteCellStyle.setWrapped(true);
//        // 设置垂直居中
//        contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
//        // 设置水平居中
//        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
//
//        return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
//
//    }
//
//    public static Collection<String> getIncludeColumnFiledNames(Class<?> clazz) {
//        Set<String> set = new HashSet<String>();
//        Field[]     fields;
//        do {
//            fields = clazz.getDeclaredFields();
//            for (int i = 0; i < fields.length; i++) {
//                set.add(fields[i].getName());
//            }
//            clazz = clazz.getSuperclass();
//        } while (clazz != Object.class && clazz != null);
//        return set;
//    }
//
//    public static Collection<String> getExcludeColumnFieldNames(Object ... fields) {
//        Set<String> excludeColumnFieldNames = new HashSet<String>();
//
//        for (Object field : fields) {
//            excludeColumnFieldNames.add(StrUtil.toString(field));
//        }
//        return excludeColumnFieldNames;
//    }


}
